local wushuang = fk.CreateSkill {
  name = "lvshi__wushuang",
  tags = { Skill.Compulsory }
}

Fk:loadTranslationTable{
  ["lvshi__wushuang"] = "无双",
  [":lvshi__wushuang"] = "锁定技，你使用非转化【杀】后，你视为对目标角色再使用之；你打出非明置【杀】时，改为明置之。",
  ["$lvshi__wushuang1"] = "修罗降世，神鬼辟易！",
  ["$lvshi__wushuang2"] = "殃云天降，修罗挥兵！",
}

local U = require "packages/utility/utility"
local DIY = require "packages/diy_utility/diy_utility"

wushuang:addEffect(fk.CardUseFinished, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(wushuang.name) and data.card.trueName == "slash" then
      return data.tos and U.isPureCard(data.card)--data.damageDealt
    end
  end,
  on_use = function(self, event, target, player, data)
    local tos = table.filter(data.tos, function (p) return not p.dead end)
    player.room:useVirtualCard(data.card.name, nil, player, tos, wushuang.name, true)
  end,
})

wushuang:addEffect(fk.BeforeCardsMove, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(wushuang.name) then
      for _, move in ipairs(data) do
        if move.from and move.from == player and move.moveReason == fk.ReasonResponse then
          local resp = player.room.logic:getCurrentEvent():findParent(GameEvent.RespondCard, true).data
          if not resp.card:isVirtual() and resp.card.trueName == "slash" then
            for _,info in ipairs(move.moveInfo) do
              if info.fromArea == Card.PlayerHand and Fk:getCardById(info.cardId).trueName == "slash"
              and not table.contains(DIY.getShownCards(player), info.cardId) then
                return true
              end
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      for _, info in ipairs(move.moveInfo) do
        DIY.showCards(player,{info.cardId})
      end
      move.moveInfo = {}
    end
  end,
})

return wushuang
